<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
    <div class="box">
        全选：<input type="checkbox" id="all"><br>
        <hr>
        <input type="checkbox">选项一<br>
        <input type="checkbox">选项二<br>
        <input type="checkbox">选项三<br>
        <input type="checkbox">选项四<br>
    </div>
    <script>
        var all = document.querySelector('input');
        var items = document.querySelectorAll('input:nth-child(n+2)')
        all.onclick = function () {
            var type = all.checked;
            for (var i = 0; i < items.length; i++) {
                items[i].checked = type;
            }
        }
        for (var i = 0; i < items.length; i++) {
            items[i].onclick = function () {
                var flag = true;
                for (var j = 0; j < items.length; j++) {
                    if (items[j].checked == false) {
                        flag = flase;
                        break;
                    }
                }
                all.checked = flag;
            }
        }
        var a =10;
        function go(){
            var b=20;
            console.log(b);
        }
        console.log(a);
    </script>
</body>
</html>